//排序顺序

// ox-util
// utility
// react
// styled-component
// component 
// hook
// state
// PropTypes


function sort(prop) {
    return function (obj1, obj2) {
      var val1 = obj1[prop]
      var val2 = obj2[prop]
          if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
              val1 = Number(val1)
              val2 = Number(val2)
          }
          if (val1 < val2) {
              return -1
          } else if (val1 > val2) {
              return 1
          } else {
              return 0
          }
      }
  }

var str = `["import {collectEvent} from 'utility/volcanoengine.js';","import {whetherShowGame} from 'utility/urlswitch.js';","","import {useRef, useCallback} from 'react';","import Tap from 'component/tap.js';","import DrawerOverlay from 'component/draweroverlay.js';","","","const a = 1","const b = 2","","const c= 3"]`
var arrorder = JSON.parse(str);

var transformNew = function(arrorder){
    return arrorder.map((item,index)=>{
        console.log(item);
        return {
            value:item,
            isImport: String(item).includes("import") && String(item).includes("from") ? true : false
        }
    })
}
console.log(arrorder);
console.log(transformNew(arrorder));
let options = [{
          id: 'styled-component',
          name: '北京',
      }, {
          id: 'ox-util',
          name: '上海'
      }, {
          id:'ox-util',
          name: '深圳'
      }, {
          id: 'react',
          name: '杭州'
      },{
        id: 'utility',
        name: 'ddddd'
    },{
        id: '',
        name: 'cccc'
    },{
        id: '',
        name: 'fffff'
    }];
      var orderby = ['ox-util','utility','react','styled-component','component','hook','state','PropTypes'];
      options.forEach(item=>{
          let sortId = orderby.indexOf(item.id)
          item.sortId = sortId;
      })
      let sortArr = options.sort(sort('sortId'))
      console.log(sortArr)